package com.slin.controller;

import com.slin.domain.Goods;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(tags = { "测试" })
@RestController
public class TestController {

    @RequestMapping(value = "/search", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
    @ApiOperation(value = "获取商品列表",notes = "")
    public List<Goods> search()
    {
        List<Goods> list = new ArrayList<>();
        Goods goods1 = new Goods();
        goods1.setId(1136439600949878786L);
        goods1.setStoreId(1L);
        goods1.setTitle("测试1");
        list.add(goods1);

        Goods goods2 = new Goods();
        goods2.setId(1136439600949878787L);
        goods2.setTitle("测试1");
        goods2.setStoreId(2L);
        list.add(goods2);
        return list;
    }



    @RequestMapping(value = "/getDetail", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
    @ApiOperation(value = "根据商品ID查询商品",notes = "")
    public Goods getDetail(Long goodsId)
    {
        Map<String,Goods> map = new HashMap<>();
        Goods goods1 = new Goods();
        goods1.setId(1136439600949878786L);
        goods1.setStoreId(1L);
        goods1.setTitle("测试1");
        map.put(goods1.getId(),goods1);

        Goods goods2 = new Goods();
        goods2.setId(1136439600949878787L);
        goods2.setTitle("测试1");
        goods2.setStoreId(2L);
        map.put(goods2.getId(),goods1);
        return map.get(goodsId);
    }
}
